<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); 

$db =& JFactory::getDBO();
$user =& JFactory::getUser();

$db->setQuery("select * from `wed_scheduler` where `user_id` = '".$user->id."' order by `id`");
$plans = $db->loadObjectList();

?>
<link rel="stylesheet" href="<?php echo JRoute::_('/modules/mod_wed_scheduler/style.css'); ?>" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JRoute::_('/modules/mod_wed_scheduler/wed_scheduler.js'); ?>"></script>
<table id="plan_table">
	<tr>
		<td width='25px'>№</td>
		<td>Задание</td>
		<td width='100px'>Отметка о выполнении</td>
		<td width='50px'>Удалить</td>
	</tr>
	<?php
	$i = 1;
	foreach ($plans as $plan) {
		echo "<tr class='plan'>";
		echo "<td class='td-center plan-number'>".($i++)."</td>";
		echo "<td><input type='text' class='task' value='{$plan->task}' /></td>";
		echo "<td class='td-center'><input type='checkbox' class='performed' ".($plan->performed ? "checked='checked'" : "")." /></td>";
		echo "<td><input type='button' class='plan_delete' value='Удалить' /></td>";
		echo "</tr>";
	}
	?>
	<tr>
		<td colspan="5" class="td-center">
			<input type="button" id="add-plan" value="Добавить" />
		</td>
	</tr>
	<tr>
		<td colspan="5">
			<input type="button" id="plans-save" value="Сохранить" />
			<span id="save_result"></span>
		</td>
	</tr>
</table>